package com.yonyou.isv.demo.openapi.api.tax.entity.input_ticket;

import com.yonyou.isv.demo.openapi.utils.Base64Util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *  进项受票-报销台账（全票中和非全票种）构造参数
 */
public class StaBookBuildParam {
    /**
     * OCR识别
     * @return
     */
    public static Map<String, Object> buildRecognisePostParam() {
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("nsrsbh", "100900110090011");
        paramsMap.put("orgCode", "1009001");
        //注意 base64编码不能有换行  选择BASE64Encoder需要将换行处理  用Base64比较好
        paramsMap.put("file", Base64Util.imageToBase64("D:\\常用文件\\税务云\\测试数据\\1.jpg"));
        //paramsMap.put("file", Base64Util.NetImageToBase64("https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1590057248&di=a298d5f9728d9ded45906a643d8b8b2d&src=http://5b0988e595225.cdn.sohucs.com/images/20180810/75d14550cff44cf4bcc0346dd50c3aae.jpeg"));
        //ImageToBase64("D:\\1.png"));
        return paramsMap;
    }
    //查验并缓存
    public static Map<String, Object> verfiy() {
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("nsrsbh", "111222333456111");
        paramsMap.put("submitter", "jgj");
        paramsMap.put("orgcode", "342423");
        paramsMap.put("invoices", buildinvoices());
        return paramsMap;
    }
    //从缓存提交到报销台账
    public static Map<String, Object> submit() {
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("nsrsbh", "111222333456111");
        paramsMap.put("submitter", "jgj");
        paramsMap.put("orgcode", "342423");
        paramsMap.put("invoices", buildSaveinvoices());
        return paramsMap;
    }
    /**
     * 识别结果保存台帐
     */
    public static Map<String,Object> OCR_Save(){
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("nsrsbh", "100900110090011");
        paramsMap.put("orgcode", "1009001");
        paramsMap.put("bills",OCR_SaveBills());

        return paramsMap;
    }


    /**
     * 保存报销票据明细
     */
    public static List<Object> OCR_SaveBills(){
        List<Object> bills = new ArrayList<Object>();
        Map<String, Object> datas = new HashMap<String, Object>();
        datas.put("imageId","60214");
        datas.put("billType","train");
        datas.put("data", OCR_SaveTrainData());
        bills.add(datas);
        return bills;
    }
    /**
     * 机打发票data
     */
    public static Map<String,Object> OCR_SaveMachineData(){
        Map<String, Object> data = new HashMap<String, Object>();
        //开票日期"yyyyMMdd"
        data.put("date","20200610");
        //消费类型
        data.put("kind","交通");
        data.put("sellerName","销方名称");
        data.put("buyerName","购方名称");
        //发票代码
        data.put("invoiceCode","211001111013");
        //发票号码
        data.put("invoiceNum","87650531");
        //购方税号
        data.put("buyerTaxId","1234");
        //校验码
        data.put("checkCode","");
        //合计金额BigDecimal
        data.put("totalAmount",9);
        //报销状态
        data.put("purchaserStatus","");
        //买方税号
        data.put("sellerTaxId",12345);
        data.put("time","");

        return data;
    }
    /**
     * 增值税发票data
     *//*

    public static  Map<String, Object> OCR_SaveInvoiceData(){
        Map<String, Object> data = new HashMap<String, Object>();
        data.put("hasExist",false);
        data.put("hjje",5000);
        data.put("xsfMc","成都郫县希望职业学校");
        data.put("gmfNsrsbh","");
        data.put("gmfMc","吴星君计算机应用");
        //售方纳税人识别号
        data.put("xsfNsrsbh","52510124551090719U");
        //发票id
        data.put("pkInvoice","0");
        data.put("jshj","5600");
        //作废标志
        data.put("zfbz","N");
        //发票代码
        data.put("fpDm","211001111012");
        //发票类型
        data.put("fplx","9");
        //报销状态
        data.put("purchaserStatus",0);
        data.put("hasattache",false);
        //开票日期
        data.put("kprq","20171018");
        //发票号码
        data.put("fpHm","87650531");
        //校验码
        data.put("jym","557129");
        //征税方式
        data.put("zsfs","0");
        //表体明细行
        data.put("items",items());
        return data;
    }
    public static List<Object>items(){
        List<Object> items = new ArrayList<Object>();
        Map<String, Object> item = new HashMap<String, Object>();
        //项目名称
        item.put("xmmc","服务费");
        //项目数量
        item.put("xmsl",1);
        //项目金额
        item.put("xmje","100");
        //税率
        item.put("sl",0.06);
        items.add(item);
        return items;
    }*/
    /**
     * 航空电子行程单DATA
     */
    public static  Map<String, Object> OCR_SaveAirData(){
        Map<String, Object> data = new HashMap<String, Object>();
        //开票日期"yyyyMMdd"
        data.put("date","20200610");
        data.put("id","20200610");
        data.put("fare",4444);

        data.put("agentCode","HKK068,08688003");
        data.put("issueBy","成都携程旅行社有限公司北京分社");
        //消费类型
        data.put("kind","交通");
        data.put("userName","www");
        data.put("userId","371102198004020527");
        data.put("caacDevelopFund",50);
        //校验码
        data.put("checkCode","");
        //合计金额BigDecimal
        data.put("totalAmount",9);
        data.put("ticketNum","8802175000276");
        //发票代码
        data.put("itemList",itemList());
        //发票号码
        data.put("fuelSurcharge",30);
        return data;
    }
   // 航空电子行程单DATA参数构造
    public static List<Object>itemList(){
        List<Object> items = new ArrayList<Object>();
        Map<String, Object> item = new HashMap<String, Object>();
        //项目名称
        item.put("id","111");
        //项目数量
        item.put("airId","123");
        item.put("date","20200610");
        //项目金额
        item.put("seat","Y");
        //税率
        item.put("carrier","海航");
        item.put("from","杭州");
        item.put("time","19:23");
        item.put("to","北京");
        item.put("flightNumber","HU7678");


        items.add(item);
        return items;
    }

    /**
     * 火车票台账data
     */
    public static  Map<String, Object> OCR_SaveTrainData(){
        Map<String, Object> data = new HashMap<String, Object>();
        //开票日期"yyyyMMdd"
        data.put("date","20200610");
        data.put("id","20200610");
        //消费类型
        data.put("kind","交通");
        data.put("origin","北京南");
        data.put("destination","北京北");
        data.put("number","P026491");
        //合计金额BigDecimal
        data.put("totalAmount",9);
        data.put("trainNum","G9");
        data.put("name","XXX");
        data.put("time","12:00");
        data.put("seatNo","二等座");

        return data;
    }

    /**
     * 出租车保存报销data
     * @return
     */

    public static  Map<String, Object> OCR_SaveTaxiData(){
        Map<String, Object> data = new HashMap<String, Object>();
        //发票代码
        data.put("invoiceCode","211001111012");
        //发票号码
        data.put("invoiceNum","87650531");
        //开票日期"yyyyMMdd"
        data.put("date","20200610");
        data.put("id","20200610");
        //消费类型
        data.put("kind","交通");
        //合计金额BigDecimal
        data.put("totalAmount",9);
        //里程
        data.put("mileage",8);
        //上车时间
        data.put("startTime","13:23");
        //结束时间
        data.put("endTime","13:25");
        //发票所在地
        data.put("place","黑龙江省哈尔滨市");
        return data;
    }

    /**
     * 台账报销
     */
    public static Map<String,Object> reimbursed(){
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("nsrsbh", "100900110090011");
        paramsMap.put("orgCode", "1009001");
        paramsMap.put("bills",reimbursedBills());
        return paramsMap;

    }
    /**
     * 台账报销参数构造
     */
    public static List<Object>  reimbursedBills(){
        List<Object> datas = new ArrayList<Object>();
        Map<String, Object> data = new HashMap<String, Object>();
        //发票代码
        data.put("invoiceCode","211001111012");
        //发票号码
        data.put("invoiceNum","87650531");
        data.put("billType","taxi");
        datas.add(data);
        return datas;
    }
    /**
     * 报销台账取消报销
     */
    public static Map<String,Object> cancelReimbursed(){
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("nsrsbh", "100900110090011");
        paramsMap.put("orgCode", "1009001");
        paramsMap.put("bills",reimbursedBills());
        return paramsMap;

    }
    /**
     * 台账记账Bills
     */
    public  static List<Object> accountBills(){
        List<Object> datas = new ArrayList<Object>();
        Map<String, Object> data = new HashMap<String, Object>();
        //发票代码
        data.put("invoiceCode","211001111012");
        //发票号码
        data.put("invoiceNum","87650531");
        data.put("billType","taxi");
        datas.add(data);
        return datas;
    }

    //新增个人票夹参数构造

    //      "srcBillCode" : "业务系统单据号",
    //      "srcapp":""
    //    },
    private static Object buildinvoices() {
        List<Object> datas = new ArrayList<Object>();
        Map<String, Object> data = new HashMap<String, Object>();
        data.put("hjje",1395.28);
        data.put("jshj",1479.00);
        data.put("fpDm","3100201130");
        data.put("kprq","20210421");
        data.put("fpHm","51143619");
        data.put("jym","162191");
        data.put("srcBillType","invoice");
        data.put("srcBillCode", "51143619");
        datas.add(data);
        return datas;
    }

    //新增个人票夹参数构造 {

    //      "srcBillCode" : "业务系统单据号",
    //      "srcapp":""
    //    },
    private static Object buildSaveinvoices() {
        List<Object> datas = new ArrayList<Object>();
        Map<String, Object> data = new HashMap<String, Object>();
        //data.put("hjje",5000);
        //data.put("jshj","5600");
        data.put("fpDm","211001111012");
        //data.put("kprq","20171018");
        data.put("fpHm","87650531");
        //data.put("jym","557129");
        data.put("srcBillType","taxi");
        //data.put("srcBillCode", "23456789");
        data.put("saveToken","0f91a474-ec93-46b1-bf3f-b5a40f1d7e26");
        data.put("srcapp","来源应用");
        datas.add(data);
        return datas;
    }
    /**
     * 报销台账删除
     */
    public  static Map<String, Object> delete(){
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("nsrsbh", "100900110090011");
        paramsMap.put("orgCode", "1009001");
        paramsMap.put("bills",accountBills());
        return paramsMap;
    }

    /**
     * 查询报销台账全票面信息
     * */
    public static Map<String,Object> queryStandingBookDetail(){
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("billCode", "12345678");
        paramsMap.put("billNum","1234567812");
        paramsMap.put("billType","invoice");
        return paramsMap;
    }

    /**
     * 报销发票入账
     * @return
     */
    public static Map<String, Object> reimbursementInvoiceEntry() {
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("nsrsbh", "100900110090011");
        paramsMap.put("orgCode", "1009001");
        List<Map<String, Object>> invoices = new ArrayList<>();
        Map<String, Object> invoice = new HashMap<String, Object>();
        invoice.put("fpDm","3100201130");
        invoice.put("fpHm","51143619");
        invoice.put("voucherid","");
        invoice.put("accountUser","20210421");
        invoice.put("accountNote","");
        invoices.add(invoice);
        paramsMap.put("invoices",invoices);
        return paramsMap;

    }

    /**
     * 报销发票取消入账
     * @return
     */
    public static Map<String, Object> reimbursementInvoiceEntryCancel() {
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("nsrsbh", "100900110090011");
        paramsMap.put("orgCode", "1009001");
        List<Map<String, Object>> invoices = new ArrayList<>();
        Map<String, Object> invoice = new HashMap<String, Object>();
        invoice.put("fpDm","3100201130");
        invoice.put("fpHm","51143619");
        invoices.add(invoice);
        paramsMap.put("invoices",invoices);
        return paramsMap;
    }

    /**
     * 全票种不需要查验进入报销台账
     * @return
     */
    public static Map<String, Object> directSave() {
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("nsrsbh", "100900110090011");
        paramsMap.put("orgCode", "1009001");
        paramsMap.put("submitter", "jgj");
        paramsMap.put("bills",buildBills());
        return paramsMap;
    }

    /**
     *构造 全票种参数集合
     */
    private static List<Map<String, Object>> buildBills() {
        List<Map<String, Object>> bills = new ArrayList<>();
        Map<String, Object> bill = new HashMap<String, Object>();
        bill.put("data",buildMachine());
        bill.put("billType","machine");
        bills.add(bill);
        return bills;
    }

    /**
     * 构造 机打发票
     * @return
     */
    private static Map<String, Object> buildMachine() {
        Map<String, Object> data = new HashMap<String, Object>();
        data.put("thirdVerifyStatus","1");
        data.put("invoiceCode","3100201130");
        data.put("invoiceNum","51143619");
        data.put("date","20190923");
        data.put("time","19:00");
        data.put("checkCode","");
        data.put("sellerName","顺德北浩敏跃渝聚食府");
        data.put("sellerTaxId","100900110090011");
        data.put("buyerName","顺德北浩敏跃渝聚食府");
        data.put("buyerTaxId","100900110090011");
        data.put("totalAmount",139);
        List<Map<String, Object>> itemList = new ArrayList();
        Map<String, Object> item = new HashMap<String, Object>();
        item.put("item","餐饮费");
        item.put("amount",100);
        itemList.add(item);
        data.put("itemList",itemList);
        return data;
    }

    /**
     * 发票预览
     * @return
     */
    public static Map<String, Object> invoiceViewUrl() {
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("nsrsbh", "100900110090011");
        paramsMap.put("orgCode", "1009001");
        List<Map<String, Object>> invoices = new ArrayList<>();
        Map<String, Object> invoice = new HashMap<String, Object>();
        invoice.put("fpDm","3100201130");
        invoice.put("fpHm","51143619");
        invoices.add(invoice);
        paramsMap.put("invoices",invoices);
        return paramsMap;
    }

}
